import VueRouter from 'vue-router'
import Vue  from 'vue'
Vue.use(VueRouter)
const routes = [
    {
        path: '',
        redirect: '/home'
    },
    {
        path: '/about',
        component: () => import('../components/About.vue'),
        beforeEnter(to, from, next) {
            console.log('beforeEnter' + to.path)
            next()
        }
    },
    {
        path: '/home',
        component: () => import('../components/Home.vue'),
        beforeEnter(to, from, next) {
            console.log('beforeEnter' + to.path)
            next()
        }
    },
]
const router = new VueRouter({
    routes
})
router.beforeEach((to,  from, next) =>{
    console.log('beforeEach' + to.path);
    next(vm => {
        console.log('before each');
    })
})
router.beforeResolve((to, from, next) => {
    console.log('beforeResolve' + to.path)
    next();
})
router.afterEach((to, from) => {
    console.log(this);
    console.log(to.path + 'aftereach');
})
export default router